#!/usr/bin/env ruby 

# Convenience script for performing snapshot restore/disaster recovery
# in standard production environments of Gitorious. 

# Restore Gitorious state (hosted repositories + database) from a
# previous snapshot. Takes optional env variable parameter to specific
# the path of specific tarball to restore from. Must be run as
# superuser/root.
# 
# (See /lib/tasks/backup.rake for more discussion of assumptions and
# use cases.)
#
# Examples:
#
# script/restore                                Restore state from ./snapshot.tar
# script/restore /tmp/backup.tar                Restore state from /tmp/backup.tar

tarball_path = ARGV[0] || "snapshot.tar"

puts "Restoring state from snapshot..."
puts `bundle exec rake backup:restore RAILS_ENV=production TARBALL_PATH=#{tarball_path}`
puts "Restore done."
